using Unity.Entities;
using Unity.Mathematics;
using UnityEngine;

namespace HelloCube
{
    public struct RotateSpeed : IComponentData
    {
        public float RadiansPerSecond;
    }

    public class RotationSpeedAuthoring : MonoBehaviour
    {
        public float DegreesPerSecond = 360f;

        class Baker : Baker<RotationSpeedAuthoring>
        {
            public override void Bake(RotationSpeedAuthoring authoring)
            {
                var entity = GetEntity(TransformUsageFlags.Dynamic);
                AddComponent(entity, new RotateSpeed
                {
                    RadiansPerSecond = math.radians(authoring.DegreesPerSecond),
                });
            }
        }
    }
}